/**
 * @file drv_i2c.h
 * @brief 
 * 
 * @author dalin (dalin@open-robot.com)
 * @version 1.0
 * @date 2023-05-11
 * 
 * @copyright Copyright (c) 2023  Open Robot Tech.co, Ltd
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2023-05-11 <td>1.0     <td>dalin     <td>内容
 * <tr><td>2023-06-02 <td>1.1     <td>dalin     <td>添加阻塞的发送和接收
 * </table>
 */

#ifndef _DRV_I2_H_
#define _DRV_I2_H_

#include "drv_config.h"
#include "drv_gpio.h"


#ifdef USE_I2C_DRIVER

typedef enum I2CNUMBER_
{
    DRV_I2C_INIT = 0,
    DRV_I2C1,
    DRV_I2C2,
    DRV_I2C3,

    DRV_I2C_NUMBER_MAX
}i2cNumber_e;

typedef enum I2CMEMSIZE_
{
    DRV_I2C_MEMSIZE_8BIT = 0,
    DRV_I2C_MEMSIZE_16BIT,
}i2cMemSize_e;


typedef struct DRV_I2C_
{
    i2cNumber_e hi2c;
    uint8_t     dev_addr;
    uint8_t     mem_addr;
    uint8_t     mem_size;
    uint32_t    timeout;
}i2cDrv_t;



/********************************** drv i2c api **********************************/
int drv_i2c_send(i2cDrv_t drv, uint8_t * data, uint16_t len);
int drv_i2c_recv(i2cDrv_t drv, uint8_t * data, uint16_t len);

int drv_i2c_ready(i2cDrv_t drv, uint8_t trials);

#endif /* USE_I2C_DRIVER */
#endif  /* _DRV_I2_H_ */
